var express = require('express');
var router = express.Router();
var path = require('path');
var url=require("url");//路由模块
const fs = require('fs');
var _path = path.join(__dirname,'../')
// =__dirname+"../views/";//指定文件路径
function SetHtml(path,req,res){
    console.info("path是",path)
    fs.readFile(path,function (err,data) {
        if (err){
            res.writeHead(404, {'Content-Type': 'text/plain'});
            res.end("加载文件失败");
        }else{
            res.writeHead(200, {'Content-Type': 'text/html','Access-Control-Allow-Origin':'*'});
            console.info(data.toString())
            res.end(data.toString());
        }
    });
}
router.get('/', function(req, res, next) {
    console.info("path是1",_path)
    res.type = 'html';
    SetHtml(_path+"wotui/index.html",req,res)
});
/* GET home page. */
router.get('/wotui', function(req, res, next) {
    console.info("path是2",_path)
    res.type = 'html';
    SetHtml(_path+"public/index.html",req,res)
});
router.get('/cd', function(req, res, next) {
    console.info("path chongding是1",_path)
    res.type = 'html';
    SetHtml(_path+"chongding/cd.html",req,res)
});
router.get('/share', function(req, res, next) {
    console.info("path chongding是1",_path)
    res.type = 'html';
    SetHtml(_path+"chongding/share.html",req,res)
});
router.get('/guide', function(req, res, next) {
    console.info("path chongding是1",_path)
    res.type = 'html';
    SetHtml(_path+"chongding/guide.html",req,res)
});
router.get('/sb', function(req, res, next) {
    console.info("path chongding是1",_path)
    res.type = 'html';
    SetHtml(_path+"chongding/zhishi.html",req,res)
});
router.get('/zhishi', function(req, res, next) {
    console.info("path chongding是1",_path)
    res.type = 'html';
    SetHtml(_path+"chongding/sb.html",req,res)
});
module.exports = router;
